import sun.nio.ch.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-16
 * Time: 10:48
 */
public class Demo1 {

    public static void main(String[] args) {
        //ExecutorService service= Executors.newCachedThreadPool();//线程扩容
     //ExecutorService service =   Executors.newFixedThreadPool(10);//创建固定线程数目的线程池
//ExecutorService service = Executors.newSingleThreadExecutor();//创建单线程的线程池
        ExecutorService service = Executors.newScheduledThreadPool(10);
        //创建固定线程数目,但任务延时执行的线程池
        for (int i = 0; i <10000 ; i++) {
            int id=i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello "+ id+", "+Thread.currentThread().getName());
                }
            },1000);
        }

    }
}
